package com.test;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;

import org.junit.Test;

import com.dingding.common.core.util.PictureRecognitionUtil;

import sun.misc.BASE64Encoder;

public class UploadPictures extends BaseTest {

	@Test
	public void getImageStr(){
		
		String imgFile = "C:/Users/hq/Desktop/行驶证/1447288283547713985.jpg";// 待处理的图片
		InputStream in = null;
		byte[] data = null;
		// 读取图片字节数组
		try {
		in = new FileInputStream(imgFile);
		data = new byte[in.available()];
		in.read(data);
		in.close();
		} catch (IOException e) {
		e.printStackTrace();
		}
		// 对字节数组Base64编码
		BASE64Encoder encoder = new BASE64Encoder();

		String str = encoder.encode(data);
		
		try {
			PictureRecognitionUtil.jszRecognition(str);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		
//		FileWriter writer;
//        try {
//            writer = new FileWriter("E:/image.txt");
//            writer.write(str);
//            writer.flush();
//            writer.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
		
	}
	
}
